package com.fy.tt.executor.node.word.noun;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fy.tt.executor.environment.Environment;

import java.util.ArrayList;
import java.util.List;

import static com.fy.tt.utils.BandCore.doGetWithAccessToken;
import static com.fy.tt.utils.BandCore.getAccessToken;


public class Stranger extends Noun {

    public String text;

    public Stranger(String text){
        this.text = text;
    }

    @Override
    public boolean run(String methodName) {
        List<JSONObject> strangers=new ArrayList<>();
        String accessToken=null;
        try{
            accessToken=getAccessToken();
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println("accessToken:"+accessToken);
        String faceUrl="https://www.wetoband.com/tre/runTool4ward?" +
                "gid=5309707&tp=deb23d4e93e9e0e56e00a5c94ab3c935ee7ed76dac7b0b8e7aca979c936c0dc09cb125a9a95fcaf245edab6d05110733113b024c4cea693b2c04e7ef7b171487bbc9734486579554d78c54e9d356862ce2960b1e9f32a6109a646c547a80a8446345434c32575ca89d341aecce4c601fa88794b196c66e53211f9d681ab38eefa6166d0112df38f76bf87d6e63778efe45575167fd7d7d51908ebae5a7c2b9967b9a0064eecb549c9e4032e179569a3103438cb1627f5431daf0f62f9f0ba383cebd8ed1a03b4552126ea9f1e444a5f4ab28e2e52514a5a8f587ccc1599f03d2d706c00276e929f8647f20b348b5b0d37aca08824ee35fd97c1ef2ae01b4254f5ccb203d4078dc0b39e1fbd056562eb4939dc432add740bb5ac1788a63e9c589681e0289b6f6ad1e6e715bc7d7727cb002a288faf5da8828de1cb6140dde396b95e0862ce930dff369e6d2a265a1f60b34fd8d0ef4ea05ddc908d9db58c4be5b26be59ee788a476cac3d631ed8544dabbba8ac0f2d9891d39d3a1f366bd08bf6f3f1ea752322f7050fc1137e97cd016811a2ca96ef434d34882a9735d35469cbc2192089ab297c1aae86209d0df97f450f9b55db527cc36157fd686a0c0ef2e36bd8c4a0ea5dfdb022932770445de0c6e1b02e03714b167969c4559cf8c4468c416e689c4b5a606951433137971d864bc05dc774f8f94fd6ef35ce153313dc4c5f89b6ba964309007d6c06489e35b04018a769d73af72ce1459ffb0350d4658a0af665d7ad09729f604325aa7cf39761ca2fa1751c0f1734a05d4ba94cb9f076381d656eb9f0e4db2ff40d5eeaa46f2ac940edabb002b462&" +
                "url_route=get_image_from_history&device_id=12";
        String Res=doGetWithAccessToken(faceUrl,accessToken);
        System.out.println("faceRes:"+Res );
        Environment.environment.put("Noun", strangers);
        JSONObject jsonObject = JSONObject.parseObject(Res);
        System.out.println("data:"+jsonObject);
        String unknown=jsonObject.getString("unknown");
        JSONArray arr= JSONArray.parseArray(unknown);
        for (Object obj:arr){
            strangers.add((JSONObject)obj);
        }
        Environment.environment.put("Object", strangers);
        return true;
    }
}
